<template>
	<view class="page">
		<u-navbar bgColor='#4871C0' :titleStyle="{ color: '#FFF'}" title="编辑内容" leftIconColor="#FFF" :autoBack="true">
		</u-navbar>
		<u-textarea class="textarea" placeholder="请输入内容" v-model="content"  height="160" auto-height>
		</u-textarea>
		<u-button class="btn" text="提交" type="primary" color="#4871C0" @click="save"></u-button>
	</view>
</template>

<script>
	import {
		getItemdata,
		saveItemdata
	} from '@/api/feedbackApi.js'
	import UButton from "../../uni_modules/uview-ui/components/u-button/u-button";
	import UTextarea from "../../uni_modules/uview-ui/components/u--textarea/u--textarea";
	export default {
		name: "feedback-edit-content",
		components: {
			UTextarea,
			UButton
		},
		data() {
			return {
				content: '',
				id: '',
				meet_id: '',
			}
		},
		onLoad(option) {
			this.id = option.id
			this.meet_id = option.meet_id;
		},
		onShow() {
			this.getData()
		},
		methods: {
			getData() {
				this.isLoading = true;
				let params = {
					department_id: this.id,
					meet_id: this.meet_id,
				};
				getItemdata(params).then(res => {
					this.isLoading = false;
					console.log(res)
					if(res.data){
						this.content = res.data.content
					}
					
				})
			},
			save() {
				this.isLoading = true;
				let params = {
					department_id: this.id,
					meet_id: this.meet_id,
					content: this.content
				};
				saveItemdata(params).then(res => {
					this.isLoading = false;
					uni.showToast({
						title: res.msg,
						icon: 'none',
						duration: 1000
					});
					if (res.code == 1) {
						var that = this;
						setTimeout(function() {
							// uni.navigateBack({
							// 	delta: 1,
							// })
							uni.navigateTo({
								url: '/pages/feedback/feedback-edit?id=' + that.meet_id + '&meet_id=' + that.meet_id
							})
						}, 2000);

					}
				})

			}
		}
	}
</script>

<style lang="scss" scoped>
	$font-color: #4871c0;

	.page {
		height: 90vh;
		background: #F8F8F8;

		.textarea {
			background-color: #FFFFFF;
			margin-top: 44px;
			min-height: 160px;
		}

		.btn {
			position: absolute;
			width: 90%;
			bottom: 10px;
			left: 20px;
		}
	}
</style>
